home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
wsc4vb24
/
async.txt
< prev
next >
Wrap
Text File
|
1999-05-23
|
29KB
|
902 lines
RS232/422/485 Serial Communications
USERS MANUAL
Version 2.0
January 22, 1999
Copyright (C) 1999
All rights reserved
MarshallSoft Computing, Inc.
Post Office Box 4543
Huntsville AL 35815
Voice : 256-881-4630
FAX : 256-880-0925
email : info@marshallsoft.com
web : http://www.marshallsoft.com
ftp : ftp://ftp.marshallsoft.com/marshallsoft
_______
____|__ | (R)
--+ | +-------------------
| ____|__ | Association of
| | |_| Shareware
|__| o | Professionals
--+--+ | +---------------------
|___|___| MEMBER
MARSHALLSOFT is a trademark of MarshallSoft Computing, Inc.
RS232/422/485 Serial Communications Page 1
C O N T E N T S
Chapter Page
1.0 The UART...................................................3
1.1 UART Types.............................................3
National 8250..........................................3
National 16450.........................................3
National 16550.........................................3
StarTech 16650.........................................3
Texas Instruments 16750................................3
1.2 UART Operation.........................................4
1.3 RS-232 Signals.........................................5
1.4 UART Registers.........................................6
1.5 Register Summary.......................................7
2.0 Modems
2.1 Modem Standards.......................................11
2.2 Flow Control..........................................12
2.3 Modem Initialization..................................13
3.0 RS422 and RS485...........................................14
4.0 Other Serial Devices......................................15
5.0 Shareware.................................................15
RS232/422/485 Serial Communications Page 2
1.0 The UART
The heart of serial communications is the "Universal Asynchronous
Receiver Transmitter", or UART for short. The UART is responsible for
controlling the computer's RS-232/422/485 port.
1.1 UART Types
UARTs can be broken down into two classes: buffered and unbuffered.
The 8250 and 16450 are unbuffer, while the 16550, 16650, and 16750
are buffered.
1.1.1 National 8250
The National 8250 was the original UART used in the IBM PC and
compatibles, and are only suitable up to 9600 baud on slower DOS
(before the IBM/AT) machines. The 8250A is somewhat faster than the
8250, but should also be limited to slower DOS machines.
1.1.2 National 16450
The National 16450 was designed to work with the IBM PC/AT (16-bit
data bus) and faster machines. Faster than the 8250, it still has a
one-byte buffer. The 16450 chip is suitable for many DOS applications
and some Windows applications up to about 38400 baud.
1.1.3 National 16550
The National 16550 features 16-byte transmit side and receive side
FIFO buffers. The interrupt trigger level (on the receive side) can
be set at 1, 4, 8 or 14 bytes. The TX FIFO trigger is fixed at 16
bytes.
The FIFOs on the original 16550 UARTs did not work. The 16550A soon
followed the 16550 and is the "standard" UART for Windows machines.
The 16550A is recommended as the minimum chip on any new serial board
purchase.
1.1.4 StarTech 16650
The StarTech 16650 features 32-byte FIFOs and on-chip flow control,
and can be run at up to 460800 baud. It is also pin for pin
compatible with the 16550 UART.
1.1.5 TI 16750
The Texas Instruments 16750 features 64-byte FIFOs and on-chip flow
control and can be run at up to 921600 baud, but is not pin for pin
compatible with the 16550 UART.
RS232/422/485 Serial Communications Page 3
1.2 UART Operation
The purpose of the UART is:
(1) To convert bytes from the CPU (Central Processing Unit) into a
serial format by adding the necessary start, stop, and parity bits to
each byte before transmission, and to then transmit each bit at the
correct baud rate.
The first bit is always the start bit, followed by 5 to 8 data bits,
(optionally) followed by the parity bit, followed by the stop bit or
bits.
(2) To convert the incoming stream (at a specified baud rate) of
serial bits into bytes by removing the start, stop, and parity bit
before being made available to the CPU.
The UART is capable of operating in one of two modes, 'polled' and
'interrupt driven'. The serial communications functions in the BIOS
use the polled method. In this approach, the CPU is typically in a
loop asking the UART over and over again if it has a byte ready. If
a byte is ready, the polling code returns the byte. But, if the next
byte comes in before the polling code is executing again, then that
byte is lost.
In the interrupt driven approach, when a byte is received by the
UART, an 'Interrupt Service Routine' (ISR) is executed immediately,
suspending temporarily whatever is currently executing. The ISR then
moves the byte from the UART to a buffer so that the application
program can later read it.
The 16550 can be programmed so that a receive (RX) interrupt is not
triggered until 4 (or 8 or 14) bytes have been received, while the
16650 can be triggered at up to 30 bytes, and the 16750 can be
triggered at up to 56 bytes. This can significantly reduce the CPU
processing time, since 14 (or 30 or 56) bytes can be moved at once.
Transmitted bytes are queued up awaiting transmission. When a byte
is moved from the UART transmitter holding register to the UART
transmitter shift register, an interrupt is generated and the next
byte is taken from the transmitter buffer by the ISR and written to
the UART holding register.
Up to 16 bytes can be written at once to the transmitter FIFO buffer
while processing one transmitter interrupt if an 16550 UART is used,
while the 16650 can write up to 32 bytes at once, and the 16750 can
write up to 64 bytes at once.
RS232/422/485 Serial Communications Page 4
1.3 RS-232 Signals
RS-232 is the name of the serial data interface standard used to
connect computers to modems.
A summary of the serial port pins and their function follows. For
more detailed information, refer to one of the many books dealing
with RS-232 interfacing.
Signal Ground Pin 7 (DB25), Pin 5 (DB9)
The SG line is used as the common signal ground, and must always be
connected.
Transmit Data Pin 2 (DB25), Pin 3 (DB9)
The TX line is used to carry data from the computer to the serial
device.
Receive Data Pin 3 (DB25), Pin 2 (DB9)
The RX li